<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>离乌人员信息登记</title>
    <meta charset="utf-8">


    <link href="../static/weiui/lib/weui.css" th:href="@{/weiui/lib/weui.css}" rel="stylesheet">
    <link href="../static/weiui/css/jquery-weui.css" th:href="@{/weiui/css/jquery-weui.css}" rel="stylesheet">
    <link href="../static/weiui/css/demos.css" th:href="@{/weiui/css/demos.css}" rel="stylesheet">

    <th:block th:include="include :: header('新增离乌申请数据')"/>
    <th:block th:include="include :: datetimepicker-css"/>

    <style type="text/css">

        .del-temp-file {
            margin: 0;
            left: 0;
            right: 0;
            top: 0;
            height: 0;
            padding: 0;
            margin: 0;
            opacity: .8;
            color: #fff;
            background: none repeat scroll 0 0 #000;
            transition: all .5s;
            -moz-transition: all .5s;
            -webkit-transition: all .5s;
            -o-transition: all .5s;
            overflow: hidden;
        }

        .del-temp-file-hover {
            cursor: pointer;
            height: 30px
        }

        .file_name {
            margin: 0;
            white-space: nowrap;
            width: 86%;
            overflow: hidden;
            -o-text-overflow: ellipsis;
            text-overflow: ellipsis;
            float: left;
        }

        .file_del {
            background: url(/img/X.png) no-repeat scroll 0 0 transparent;
            width: 18px;
            height: 18px;
            display: inline;
            -moz-user-select: none;
            position: absolute;
        }


    </style>
</head>

<body ontouchstart>

<div class="weui-tab">
    <div class="weui-tab__bd">
        <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
            <div class="wrapper wrapper-content animated fadeInRight ibox-content">
                <form class="form-horizontal m" id="form-lwsq-edit" style="padding-bottom: 35px"
                      th:object="${applicationInfo}">

                    <div class="form-group" style="text-align: center;font-size: 20px;font-weight: bold">
                        <span class="col-sm-12 ">离乌人员个人信息</span>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">申请人姓名：</label>
                        <div class="col-sm-8">
                            <input id="xm" name="xm" minlength="2" th:field="*{xm}" class="form-control" type="text"
                                   required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">性别：</label>
                        <div class="col-sm-8">
                            <select name="xb" class="form-control" th:with="type=${@dict.getType('sys_user_sex')}"
                                    required>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}" th:field="*{xb}"></option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label ">年龄：</label>
                        <div class="col-sm-8">
                            <input name="by3" class="form-control" placeholder="请输入年龄" type="number"
                                   th:field="*{by3}" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">民族：</label>
                        <div class="col-sm-8">
                            <select name="mz" class="form-control" th:with="type=${@dict.getType('b_ry_mz')}" required>
                                <option value=""></option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}" th:field="*{mz}"></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">申请人手机号码：</label>
                        <div class="col-sm-8">
                            <input name="sjhm" th:field="*{sjhm}" class="form-control" type="number" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">人员类型：</label>
                        <div class="col-sm-8">
                            <select name="sfjn" class="form-control " style="color: blue"
                                    th:with="type=${@dict.getType('b_rylx')}" required>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}" th:field="*{sfjn}"></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">近3天是否有发热、咳嗽等症状：</label>
                        <div class="col-sm-8">
                            <select name="styc" class="form-control " th:with="type=${@dict.getType('sys_yes_no')}"
                                    required>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}" th:field="*{styc}"></option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">证件类型：</label>
                        <div class="col-sm-8">
                            <select name="zjlx" id="zjlx" class="form-control" style="color: blue"
                                    th:with="type=${@dict.getType('b_zjlx')}" required>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}" th:field="*{zjlx}"></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">证件号码：</label>
                        <div class="col-sm-8">
                            <input name="zjhm" th:field="*{zjhm}" class="form-control" placeholder="请输入您的证件号码(用于身份核验)"
                                   type="text" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">入乌日期：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="rwrq" th:value="${#dates.format(applicationInfo.rwrq, 'yyyy-MM-dd')}"
                                       class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">暂住所类型：</label>
                        <div class="col-sm-8">
                            <select onchange="isshowFJH()" id="zzslx" name="zzslx" class="form-control"
                                    th:with="type=${@dict.getType('b_zzslx')}" required>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}" th:field="*{zzslx}"></option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">宾馆/酒店名称/住所详细地址：</label>
                        <div class="col-sm-8">
                            <textarea name="xxdz" class="form-control" placeholder="如宾馆/酒店名称/住所所在道路、门牌号、小区、楼栋号、单元室等"
                                      th:field="*{xxdz}" required></textarea>
                        </div>
                    </div>

                    <div class="form-group" id="fjh">
                        <label class="col-sm-3 control-label ">房间号：</label>
                        <div class="col-sm-8">
                            <input name="by1" class="form-control" placeholder="房间号" th:field="*{by1}" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">入住时间：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="by4" class="form-control" id="by4" placeholder="yyyy-MM-dd HH:mm:ss"
                                       type="text" th:field="*{by4}" required>
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>
                    <hr/>

                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">在乌居住（滞留）地所属社区</label>
                    </div>
                    <div class="form-group" id="shequmingcheng">
                        <div class="col-sm-12">
                            <label class="col-sm-3 control-label " th:text="所属社区："></label>
                            <label class="col-sm-8 control-label " id="sqNameLabel" th:text="*{sqName}"></label>
                        </div>
                    </div>


                    <div id="element1" class="row">
                        <div class="col-sm-2">
                            <select id="quyu" class="quyu form-control m-b" data-first-title="选择区域">
                                <option value="" th:field="*{sqName}">请选择</option>
                                <option value="天山区" selected>天山区</option>
                            </select>
                        </div>
                        <div class="col-sm-2">
                            <select id="jiedao" class="jiedao form-control m-b" data-first-title="选择街道">
                                <option value="">请选择</option>
                                <option value="燕儿窝街道" selected>燕儿窝街道</option>
                            </select>
                        </div>
                        <div class="col-sm-2">
                            <select id="shequ" class="shequ form-control m-b" data-first-title="选择社区">
                                <option value="红雁池社区" selected>红雁池社区</option>
                            </select>
                        </div>
                    </div>

                    <input name="sqName" id="sqName" type="hidden" th:field="*{sqName}"/>
                    <input name="sqCode" id="sqCode" type="hidden" th:field="*{sqCode}"/>
                    <input name="id" id="id" type="hidden" th:field="*{id}"/>
                    <input name="spzt" id="spzt" type="hidden" th:field="*{spzt}"/>


                    <div class="form-group">
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="ck" id="ck" type="checkbox" checked>本人承诺:以上所填写内容真实,完整,
                                如有虚假,由本人承担一切责任!
                            </div>
                        </div>
                    </div>

                    <div class="form-group" style="color: green;text-align: center;font-size: 16px">
                        <label th:if=" ${applicationInfo.spzt} eq 'SHTG' " class="col-sm-12 control-label">审批通过</label>
                    </div>

                    <div class="form-group" style="color: green;text-align: center;font-size: 16px">
                        <label th:if=" ${applicationInfo.spzt} eq 'SQLW' " class="col-sm-12 control-label">已申请离乌</label>
                    </div>

                    <div class="col-md-12">
                        <div class="form-group">
                            <div class="col-sm-12 " style="text-align: center;">

                                <button th:if=" ${applicationInfo.spzt} ne 'SHTG' and  ${applicationInfo.spzt} ne 'SQLW'  "
                                        id="bottonsubmit" type="button" onclick="submitHandler()"
                                        class="btn btn-primary">提交
                                </button>
                                <button class="btn btn-danger" onclick="javascript:history.go(-1)" type="button">关闭
                                </button>
                            </div>
                        </div>
                    </div>

                </form>
            </div>
        </div>

        <div id="tab2" class="weui-tab__bd-item">

            <div class="wrapper wrapper-content animated fadeInRight ibox-content">
                <form class="form-horizontal m" id="form-lwsq-shenqing" style="padding-bottom: 35px"
                      th:object="${applicationInfo}">
                    <div class="form-group" style="text-align: center;font-size: 16px;font-weight: bold">
                        <span class="col-sm-12 ">提交离乌申请</span>
                    </div>
                    <input name="id" id="sqid" type="hidden" th:field="*{id}"/>
                    <input name="spzt" id="sqspzt" type="hidden" th:field="*{spzt}"/>

                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">离乌事由：</label>
                        <div class="col-sm-8">
                            <textarea name="by2" rows="3" class="form-control" placeholder="离乌事由" required
                                      th:field="*{by2}"></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">离乌方式：</label>
                        <div class="col-sm-8">
                            <select name="lwfs" class="form-control " style="color: blue"
                                    th:with="type=${@dict.getType('b_jtfs')}" required>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}" th:field="*{lwfs}"></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">车牌号/航班号/车次号：</label>
                        <div class="col-sm-8">
                            <input name="cphm" class="form-control" placeholder="请输入您的车牌号/航班号/车次等,例:新A8888" required
                                   type="text" th:field="*{cphm}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">预期离乌日期：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="yqlwrq" th:value="${#dates.format(applicationInfo.yqlwrq, 'yyyy-MM-dd')}"
                                       class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">离乌目的地：</label>
                        <div class="col-sm-8">
                            <input name="fcmdd" class="form-control" placeholder="请输入您的返程目的地" type="text" required
                                   th:field="*{fcmdd}">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">核酸检测日期：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="hsjcRq" th:value="${#dates.format(applicationInfo.hsjcRq, 'yyyy-MM-dd')}"
                                       required class="form-control" placeholder="yyyy-MM-dd" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label ">双抗检测日期：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="skjcRq" th:value="${#dates.format(applicationInfo.skjcRq, 'yyyy-MM-dd')}"
                                       class="form-control" placeholder="yyyy-MM-dd" type="text" >
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>

                    <input name="by9" id="by9" type="hidden"/>

                    <div class="weui-cells weui-cells_form">
                        <div class="weui-cell">
                            <div class="weui-cell__bd">
                                <div class="weui-uploader">
                                    <div class="weui-uploader__hd">
                                        <label class="weui-uploader__title control-label is-required">核酸检测报告<span
                                                style="font-size:10px">（现场拍照或从相册选择）</span></label>
                                    </div>
                                    <div class="weui-uploader__bd">
                                        <ul class="weui-uploader__files" id="uploaderFiles">

                                        </ul>
                                        <ul class="weui-uploader__files" th:each=" p : ${pics}">
                                            <li class="weui-uploader__file"><img width="80px" height="80px"
                                                                                 th:src="'https://xjzd.zxingyun.cn:8089/'+${p}">
                                            </li>
                                        </ul>
                                        <div class="weui-uploader__input-box"
                                             th:if=" ${applicationInfo.spzt} ne 'SHTG' and  ${applicationInfo.spzt} ne 'SQLW' ">
                                            <input id="uploaderInput" class="weui-uploader__input"
                                                   type="file" accept="image/*" multiple=""
                                                   onchange="readAsDataURL(0)">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="ck" id="ck" type="checkbox" checked>本人承诺:以上所填写内容真实,完整,
                                如有虚假,由本人承担一切责任!
                            </div>
                        </div>
                    </div>

                    <div class="form-group" style="color: green;text-align: center;font-size: 16px">
                        <label th:if=" ${applicationInfo.spzt} eq 'SHTG' " class="col-sm-12 control-label">审批通过</label>
                    </div>

                    <div class="form-group" style="color: green;text-align: center;font-size: 16px">
                        <label th:if=" ${applicationInfo.spzt} eq 'SQLW' " class="col-sm-12 control-label">已申请离乌</label>
                    </div>

                    <div id="loading" class="form-group"
                         style="color: green;text-align: center;font-size: 16px;display: none">
                        <i class="weui-loading"></i>
                    </div>
                    <div class="col-md-12">
                        <div class="form-group">
                            <div class="col-sm-12 " style="text-align: center;">

                                <button th:if=" ${applicationInfo.spzt} ne 'SHTG' and  ${applicationInfo.spzt} ne 'SQLW'  "
                                        id="bottonsubmit" type="button" onclick="sqsubmitHandler()"
                                        class="btn btn-primary">提交
                                </button>
                                <button class="btn btn-danger" onclick="javascript:history.go(-1)" type="button">关闭
                                </button>
                            </div>
                        </div>
                    </div>

                </form>
            </div>
        </div>


        <div id="tab4" class="weui-tab__bd-item ">

            <div class="wrapper wrapper-content animated fadeInRight ibox-content">
                <form class="form-horizontal m" id="form-lwsq-chaxun" style="padding-bottom: 35px"
                      th:object="${applicationInfo}"
                      action="/api/lwsq/lwsq/getByCardId" method="post" >
                    <div class="form-group"
                         style="text-align: center;font-size: 16px;font-weight: bold ;margin: 30px 0px 50px 0px">
                        <span class="col-sm-12 ">个人离乌二维码</span>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">审核状态：</label>
                        <label class="col-sm-8 control-label"
                               th:text="${@dict.getLabel('b_spzt', applicationInfo.spzt)}"></label>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">审核意见：</label>
                        <label class="col-sm-8 control-label"  th:text="*{shyj}"></label>
                    </div>
                    <hr/>
                    <div class="col-md-12" style="text-align: -webkit-center;">
                        <div class="form-group">
                            <div class="col-sm-12" style="    text-align: center;">
                                <span id="findresult" style="font-weight: bold;font-size: 14px;color: red">无法生成个人离乌二维码，审核通过后，才可生成离乌二维码</span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="form-group">
                            <div class="col-sm-12">
                                <dev id="qcode"></dev>
                            </div>
                        </div>
                    </div>


                </form>
            </div>
        </div>
    </div>

    <div class="weui-tabbar">
        <a href="#tab1" class="weui-tabbar__item weui-bar__item--on">
            <div class="weui-tabbar__icon">
                <img src="/weiui/images/icon_nav_msg.png" alt="">
            </div>
            <p class="weui-tabbar__label">修改</p>
        </a>
        <a href="#tab2" class="weui-tabbar__item">
            <div class="weui-tabbar__icon">
                <img src="/weiui/images/icon_nav_article.png" alt="">
            </div>
            <p class="weui-tabbar__label">离乌申请</p>
        </a>

        <a href="#tab4" class="weui-tabbar__item">
            <div class="weui-tabbar__icon">
                <img src="/weiui/images/icon_nav_cell.png" alt="">
            </div>
            <p class="weui-tabbar__label">审核状态</p>
        </a>
    </div>
</div>
<script src="../static/js/xj.city.js" th:src="@{/js/xj.city.js}"></script>
<script src="../static/weiui/lib/jquery-2.1.4.js" th:src="@{/weiui/lib/jquery-2.1.4.js}"></script>
<script src="../static/weiui/lib/fastclick.js" th:src="@{/weiui/lib/fastclick.js}"></script>
<script src="../static/weiui/js/jquery-weui.js" th:src="@{/weiui/js/jquery-weui.js}"></script>
<script src="../static/js/qrcode.min.js" th:src="@{/js/qrcode.min.js}"></script>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: jquery-cxselect-js"/>

<script th:inline="javascript">
    var prefix = ctx + "api/lwsq/lwsq";

    $("#form-lwsq-edit").validate({
        rules: {
            focusCleanup: true,
            by2: {
                required: true,
            },
            by3: {
                required: true,
                max: 200,
                min: 1
            },
            sjhm: {
                isPhone: true
            },
            zjhm: {
                required: true,
                isIdentity: true
            },
        },

    });


    var data = init_xj_city_picker;
    var qrcode = new QRCode(document.getElementById("qcode"), {
        width: 201,
        height: 201
    })

    var spzt = $("#spzt").val();
    if (spzt == 'SHTG') {
        $("#findresult").html('审核通过，个人二维码如下');
        var id = $("#id").val();
        qrcode.makeCode(id.replace("invitation", "main"))
    }

    $(function () {
        //证件类型
        $("#zjlx").change(function () {
            $.validate.reset();
            var type = $("#zjlx").find("option:selected").val();
            if ("sfz" == type) {
                $("#zjhm").rules("remove");
                $("#zjhm").rules("add", {required: true, isIdentity: true, messages: {required: "请正确输入您的身份证号码"}});
            } else {
                $("input[name=zjhm]").rules("remove");
                $("#zjhm").rules("add", {required: true, messages: {required: "必填项，不能跳过"}});
                $("#zjhm").attr("placeholder","请填写证件号码");
            }
        });

    });

    function submitHandler() {
        if ($("#sqCode").val() == "" || $("#sqCode").val() == null) {
            $.modal.alertWarning("请选择所属社区！便于社区人员联系")
            return
        } else {
            if ($("#shequ").find("option:selected").val() != undefined) {
                $("#sqName").val($("#shequ").find("option:selected").text())
                $("#sqCode").val($("#shequ").find("option:selected").val())
            }

            if ($.validate.form()) {
                $.operate.post(prefix + "/edit", $('#form-lwsq-edit').serialize());
            }
            return;
        }
    }

    $("#form-lwsq-shenqing").validate({
        rules: {
            by2: {
                required: true,
            },
            yqlwrq: {
                required: true,
            }
        },
        focusCleanup: true
    });

    function sqsubmitHandler() {

        $("#sqspzt").val('SQLW')

        if ($.validate.form("form-lwsq-shenqing")) {

            if ($("#uploaderInput").val() == "") {
                    $.modal.alertWarning("必须上传个人核算检测报告和双抗检测报告！否则不会审核通过")
                    return

                $.operate.post(prefix + "/edit", $('#form-lwsq-shenqing').serialize());
            } else {

                do_upload();

            }

        }
    }


    function isshowFJH() {
        if ($("#zzslx").val() == "jd") {
            $("#fjh").css("display", "");
        } else {
            $("#fjh").css("display", "none");
        }
    }

    $("input[name='shclsj']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='rwrq']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='yqlwrq']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='jcbgRq']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='hsjcRq']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='skjcRq']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });


    //修改页面 入乌日期小于今日日期
    $("input[name='rwrq']").change(function () {
        var thetime = $(this).val();
        var d = new Date(Date.parse(thetime.replace(/-/g, "/")));
        var curDate = new Date();
        if (d > curDate) {
            $.modal.alertWarning("请选择正确的日期！！")
            $(this).val("");
            $(this).focus();
        }
    });


    //离乌申请页面 离乌日期不可小于今日日期
    $("input[name='yqlwrq']").change(function () {
        var thetime = $(this).val();
        var d = new Date(Date.parse(thetime.replace(/-/g, "/")));
        var curDate = new Date();
        if (d < curDate) {
            $.modal.alertWarning("请选择正确的日期！！")
            $(this).val("");
            $(this).focus();
        }
    });

    //离乌申请页面 核酸检测日期不可小于离乌日期
    $("input[name='hsjcRq']").change(function () {
        var hsjcRq = $(this).val();
        var yqlwrq = $("input[name='yqlwrq']").val()
        var hsjcRqFinal = new Date(Date.parse(hsjcRq.replace(/-/g, "/")));
        var yqlwrqFinal = new Date(Date.parse(yqlwrq.replace(/-/g, "/")));

        if (yqlwrqFinal < hsjcRqFinal) {
            $.modal.alertWarning("请重新填写日期，核酸检测日期应小于离乌日期！！")
            $(this).val("");
            $(this).focus();
        }
    });

    //离乌申请页面 双抗检测日期不可小于离乌日期
    $("input[name='skjcRq']").change(function () {
        var skjcRq = $(this).val();
        var yqlwrq = $("input[name='yqlwrq']").val()
        var skjcRqFinal = new Date(Date.parse(skjcRq.replace(/-/g, "/")));
        var yqlwrqFinal = new Date(Date.parse(yqlwrq.replace(/-/g, "/")));

        if (yqlwrqFinal < skjcRqFinal) {
            $.modal.alertWarning("请重新填写日期，抗体检测日期应小于离乌日期！！")
            $(this).val("");
            $(this).focus();
        }
    });

    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#by4',
            type: 'datetime',
            trigger: 'click'
        });
    });


    $('#element1').cxSelect({
        selects: ['quyu', 'jiedao', 'shequ'],
        jsonName: 'name',
        jsonValue: 'code',
        jsonSub: 'children',
        data: data
    });


    isshowFJH();
    var fileTypeArr = ['jpg', 'gif', 'jpeg', 'png'];//文件格式限制
    var fileSizeControl = 8;//文件大小控制 单位: MB
    var allFile = [];//所有上传文件数组初始化 注：将根据此数组上传至后台

    //验证上传的图片在allfile中是否有重复值 返回值为 true false
    function upPic_repeat(name) {
        var rFlag = false;

        $.each(allFile, function (k, v) {
            if (v.name == name) {
                rFlag = true;
            }
        })

        return rFlag;
    }

    //图片验证大小和格式
    function picVal(obj) {
        //验证格式
        if ($.inArray(obj.type.substr(6), fileTypeArr) == -1) {
            alert("格式错误~");
            return false;
        }

        //验证大小
        if (obj.size >= fileSizeControl * 1024 * 1024) {
            alert("文件不能超过3MB~");
            return false;
        }
        return true;
    }

    //图片移入删除按钮显示
    function showDel(obj) {
        obj.addClass("del-temp-file-hover");
    }

    //图片移出删除按钮消失
    function hideDel(obj) {
        obj.removeClass("del-temp-file-hover");
    }

    //删除浏览图片方法
    function real_delFile(obj) {
        var fileName = obj.parents('.del-temp-file').find('.file_name')
            .html();
        var delFlag;

        //从文件集合的数组中删除这个文件
        $.each(allFile, function (k, v) {
            if (fileName == v.name) {
                delFlag = k;//储存键
            }
        })

        allFile.splice(delFlag, 1);//删除对应键位数据 防止数组长度问题出现的报错
        obj.parents('.weui-uploader__file').remove();//将这个文件从页面浏览中删除

    }

    /**
     * 获取浏览图片页面追加元素
     * @param tempUrl 返回的BASE64临时图片位置地址
     */
    function getHtmlFile(obj, tempUrl) {
        var cons = '<li class="weui-uploader__file" style="background-image:url('
            + tempUrl
            + ')">'
            + '<div style="height:100%" >'
            + '<div class="del-temp-file" style="height:30%" onclick="showDel($(this))" onmouseleave="hideDel($(this))">'
            + '<div style="padding:5px;">'
            + '<p class="file_name">'
            + obj.name
            + '</p>'
            + '<span class="file_del" data-index="0" title="删除" onclick="real_delFile($(this))"></span>'
            + '</div>' + '</div>' + '</div>' + '</li>';
        return cons;
    }

    //该方法将文件读取为一段以 data: 开头的字符串，这段字符串的实质就是 Data URL，Data URL是一种将小文件直接嵌入文档的方案。
    function readAsDataURL(namenum) {
        //检验是否为图像文件
        var fileObj = $('#uploaderInput'); //获取图像临时路径
        var flagLength = 0;//文件循环标记
        var reader = new FileReader(); //初始化FileReader
        var valres = true;//图像验证标记
        var tempFileName;//临时上传图片标记 验证重复值使用

        //多文件上传
        $.each(fileObj[0].files, function (k, v) {
            valres = picVal(v);//图片大小和格式验证
        })
        if (valres == false) {
            return false;
        }

        reader.readAsDataURL(fileObj[0].files[flagLength]);
        reader.onabort = function (e) {
            p("文件读取异常" + tempFileName);
        };
        reader.onerror = function (e) {
            p("文件读取出现错误" + tempFileName);
        };

        reader.onload = function (e) {
            tempFileName = fileObj[0].files[flagLength].name;
            if (e.target.result) {
                if (!upPic_repeat(tempFileName)) {//重复上传图片验证
                    $("#uploaderFiles").append(
                        getHtmlFile(fileObj[0].files[flagLength],
                            reader.result));//加入模态框浏览

                    fileObj[0].files[flagLength]['tempUrl'] = reader.result;//临时浏览路径
                    fileObj[0].files[flagLength]['flagNums'] = namenum;//文件标记
                    allFile.push(fileObj[0].files[flagLength]);//将文件对象放入数组中

                } else {
                    alert('上传图片重复~');
                }

                flagLength++;//控制循环次数
                if (flagLength < fileObj[0].files.length) {
                    reader.readAsDataURL(fileObj[0].files[flagLength]);//读取文件 再次调用onload
                }
            }
        };

    }

    //开始上传图片
    function do_upload() {
        $("#loading").css("display", "");

        //整理最终上传文件
        var nameFlags = 0;//重写文件名命名标记
        var tempFile = [];//临时文件对象存储变量

        $.each(allFile, function (k, v) {
            tempFile.push(new File([v], nameFlags.toString() + '.'
                + v.type.substr(6), {
                type: v.type
            }));//重建文件 加入数组
            nameFlags++;
        })

        var formData = new FormData();//FormData 转换成二进制文件上传至后台
        // var form = document.forms.namedItem("fileinfo");
        // var formData = new FormData(form);
        formData.append('aid', $("#sqid").val())
        formData.append('filepath', 'd:/')
        for (var i = 0; i < tempFile.length; i++) {
            formData.append('files', tempFile[i]);
        }

        $.ajax({
            url: prefix + "/upload",
            type: 'POST',
            data: formData, // 上传formdata封装的数据
            dataType: 'JSON',
            cache: false, // 不缓存
            async: false,
            processData: false, // jQuery不要去处理发送的数据
            contentType: false, // jQuery不要去设置Content-Type请求头
            success: function (res) { //成功回调
                if (res.code == "0") {
                    $("#by9").val(res.data);
                    $.operate.post(prefix + "/edit", $('#form-lwsq-shenqing').serialize());
                    $("#loading").css("display", "none");
                }
            }
        });
    }
</script>
</body>
</html>
